/*
 * =====================================================================================
 *
 *       Filename:  fixture_test.cpp
 *
 *    Description:  测试套件的简单示例
				
 *
 *        Version:  1.0
 *        Created:  2008年09月24日 16时43分19秒
 *       Revision:  none
 *       Compiler:  g++
 *		   Create:  g++ -o fixture_test fixture_test.cpp -lgtest
 *
 *         Author:  ZhixiongHong (hzx), fishwarter@gmail.com
 *        Company:  Unioncast
 *
 * =====================================================================================
 */

#include <iostream>
#include <list>
#include <gtest/gtest.h>

using namespace std;
using namespace testing;


class ListTest: public Test
{
protected:
	virtual void SetUp()
	{
		li0.push_back(0);	
		li1.push_back(1);	
		li2.push_back(2);	
	}
	
	list<int> 	li0;
	list<int> 	li1;
	list<int> 	li2;
};


TEST_F(ListTest, IsEmptyInitially)
{
	EXPECT_EQ(0, li0.size()) << " not empty " << endl;
}


/*
   1. Google Test constructs a QueueTest object (let's call it t1 ).
   2. t1.SetUp() initializes t1 .
   3. The first test ( IsEmptyInitially ) runs on t1 .
   4. t1.TearDown() cleans up after the test finishes.
   5. t1 is destructed.
   6. The above steps are repeated on another QueueTest object, this time running the DequeueWorks test. 
 */

TEST_F(ListTest, DequeueWorks)
{
	li0.pop_front();
	EXPECT_EQ(0, li0.size()) << " not empty " << endl;	
}

int main(int argc, char** argv)
{
	InitGoogleTest(&argc, argv);
	
	/*
   1. Saves the state of all Google Test flags.
   2. Creates a test fixture object for the first test.
   3. Initializes it via SetUp().
   4. Runs the test on the fixture object.
   5. Cleans up the fixture via TearDown().
   6. Deletes the fixture.
   7. Restores the state of all Google Test flags.
   8. Repeats the above steps for the next test, until all tests have run. 
     */
	return RUN_ALL_TESTS();	
}
